package com.ant.rxjava.webtest.ui;

import android.databinding.DataBindingUtil;
import android.text.TextUtils;
import android.view.View;

import com.ant.rxjava.webtest.R;
import com.ant.rxjava.webtest.app.MyApplication;
import com.ant.rxjava.webtest.databinding.AcIndexLayoutBinding;
import com.ant.rxjava.webtest.ui.base.BaseActivity;

/**
 * Created by Ant on 2018/2/8  10:00
 * <p>
 * <p>
 *
 * @version 1.0.0
 * @auther Ant
 */

public class IndexActivity extends BaseActivity implements View.OnClickListener {

    private AcIndexLayoutBinding binding;

    @Override
    public void initLayout() {
        binding = DataBindingUtil.setContentView(this, R.layout.ac_index_layout);
        initToolBar();
        setTitle("配置URL");
        setResult(RESULT_CANCELED);
    }

    @Override
    public void initView() {

    }

    @Override
    public void initListener() {
        binding.acIndexObtClean.setOnClickListener(this);
        binding.acIndexObtOk.setOnClickListener(this);
    }

    @Override
    public void initData() {

    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.ac_index_edt:

                break;
            case R.id.ac_index_obt_clean:
                binding.acIndexEdt.setText("");
                break;
            case R.id.ac_index_obt_ok:
               String str=binding.acIndexEdt.getText().toString();
                if(!TextUtils.isEmpty(str)){
                   ((MyApplication)getApplication()).getConstant().setUrl(str);
                    setResult(RESULT_OK);
                    finish();
                }
                break;
        }
    }
}
